<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>注册页面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/bookList1.css">
    <style>
        .register-container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: linear-gradient(135deg, #181c2b 0%, #232946 100%);
        }
        .register-card {
            background: rgba(30, 34, 54, 0.95);
            padding: 40px;
            border-radius: 12px;
            box-shadow: 0 8px 32px #1e90ff22;
            width: 100%;
            max-width: 400px;
        }
        .register-card h2 {
            text-align: center;
            color: #1e90ff;
            margin-bottom: 20px;
        }
        .form-control {
            background: #232946;
            color: #fff;
            border: 1px solid #1e90ff;
        }
        .form-control:focus {
            box-shadow: 0 0 8px #1e90ff88;
        }
        .btn-primary {
            background: #1e90ff;
            border-color: #1e90ff;
        }
        .btn-primary:hover {
            background: #181c2b;
            border-color: #1e90ff;
        }
    </style>
</head>
<body>
<div class="register-container">
    <div class="register-card">
        <h2>用户注册</h2>
        <form action="registerServlet" method="post" onsubmit="return checkForm()">
            <div class="mb-3">
                <label for="username" class="form-label">用户名</label>
                <input type="text" class="form-control" id="username" name="username" required>
            </div>
            <div class="mb-3">
                <label for="password" class="form-label">密码</label>
                <input type="password" class="form-control" id="password" name="password" required>
            </div>
            <div class="mb-3">
                <label for="confirmPassword" class="form-label">确认密码</label>
                <input type="password" class="form-control" id="confirmPassword" name="confirmPassword" required>
            </div>
            <button type="submit" class="btn btn-primary w-100">注册</button>
            <div class="text-center mt-3">
                <a href="login.jsp" class="text-white">已有账号？立即登录</a>
            </div>
        </form>
        <% String errorMsg = (String) request.getAttribute("errorMsg"); %>
        <% if (errorMsg != null) { %>
        <div class="error-message text-center mt-3"><%= errorMsg %></div>
        <% } %>
    </div>
</div>
<script>
    function checkForm() {
        var password = document.getElementById("password").value;
        var confirmPassword = document.getElementById("confirmPassword").value;
        if (password !== confirmPassword) {
            alert("两次输入的密码不一致！");
            return false;
        }
        return true;
    }
</script>
</body>
</html>